package com.ihd.ihardware.view.tzc.health.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.view.View;

import com.ihd.ihardware.R;
import com.ihd.ihardware.databinding.DataFragmentBinding;
import com.ihd.ihardware.pojo.NormRes;
import com.ihd.ihardware.pojo.Test_rp;
import com.ihd.ihardware.view.tzc.health.viewmodel.ReportViewModel;

import cn.wowjoy.commonlibrary.base.BaseFragment;

public class DataDetailFragment extends BaseFragment<DataFragmentBinding, ReportViewModel> {
    private NormRes.DataBean tr;
    private Test_rp mTest_rp;

    public static Fragment newInstance(NormRes.DataBean tr, Test_rp test_rp) {
        DataDetailFragment fragment = new DataDetailFragment();
        fragment.setArg(tr, test_rp);
        return fragment;
    }

    private void setArg(NormRes.DataBean tr, Test_rp test_rp) {
        this.tr = tr;
        this.mTest_rp = test_rp;
    }

    @Override
    protected void onCreateViewLazy(Bundle savedInstanceState) {
        iniData();
    }

    private void iniData() {
        binding.value.setText(mTest_rp.getItem() + "：" + mTest_rp.getValue());
        binding.desc.setText(tr.getDescription());
        binding.desc2.setText(tr.getDescription2());
        if (TextUtils.isEmpty(tr.getSuggest()))
            binding.hint.setVisibility(View.GONE);
        else {
            binding.hint.setVisibility(View.VISIBLE);
            binding.hint.setText(tr.getSuggest());
        }
        binding.bmiHint.setText(tr.getStateDes());
        binding.line0.setVisibility(View.VISIBLE);
        binding.line1.setVisibility(View.VISIBLE);
        binding.line2.setVisibility(View.VISIBLE);
        binding.line3.setVisibility(View.VISIBLE);
        binding.line4.setVisibility(View.VISIBLE);
        binding.linep.setBackgroundColor(getContext().getResources().getColor(R.color.C_0));
        binding.linepc.setImageResource(R.drawable.circle_0);
        binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_6));
        binding.line5c.setImageResource(R.drawable.circle_6);
        binding.v1.setVisibility(View.VISIBLE);
        binding.v2.setVisibility(View.VISIBLE);
        binding.v3.setVisibility(View.VISIBLE);
        binding.v4.setVisibility(View.VISIBLE);
        binding.line.setVisibility(View.GONE);
        binding.i0.setVisibility(View.GONE);
        binding.i0.setImageResource(R.drawable.circle_0);
        binding.h0.setVisibility(View.GONE);
        binding.i1.setVisibility(View.GONE);
        binding.i1.setImageResource(R.drawable.circle_1);
        binding.h1.setVisibility(View.GONE);
        binding.i2.setVisibility(View.GONE);
        binding.i2.setImageResource(R.drawable.circle_2);
        binding.h2.setVisibility(View.GONE);
        binding.i3.setVisibility(View.GONE);
        binding.i3.setImageResource(R.drawable.circle_3);
        binding.h3.setVisibility(View.GONE);
        binding.i4.setVisibility(View.GONE);
        binding.i4.setImageResource(R.drawable.circle_4);
        binding.h4.setVisibility(View.GONE);
        binding.i5.setVisibility(View.GONE);
        binding.i5.setImageResource(R.drawable.circle_5);
        binding.h5.setVisibility(View.GONE);
        binding.i6.setVisibility(View.GONE);
        binding.i6.setImageResource(R.drawable.circle_6);
        binding.h6.setVisibility(View.GONE);

        int pro = 0;
        switch (tr.getType()) {
            case 1:
                binding.img.setImageResource(R.drawable.detail_icon_body_1feipangdu);
                binding.bg.setImageResource(R.drawable.bg_fpd);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i1.setVisibility(View.VISIBLE);
                binding.h1.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i3.setVisibility(View.VISIBLE);
                binding.h3.setVisibility(View.VISIBLE);
                binding.i4.setVisibility(View.VISIBLE);
                binding.h4.setVisibility(View.VISIBLE);
                binding.i5.setVisibility(View.VISIBLE);
                binding.h5.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("消瘦");
                binding.h1.setText("偏瘦");
                binding.h2.setText("标准");
                binding.h3.setText("超重");
                binding.h4.setText("轻度");
                binding.h5.setText("中度");
                binding.h6.setText("重度");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setText(tr.getNormArr().get(1));
                binding.v2.setText(tr.getNormArr().get(2));
                binding.v3.setText(tr.getNormArr().get(3));
                binding.v4.setText(tr.getNormArr().get(4));
                binding.v5.setText(tr.getNormArr().get(5));
                double db = Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1));
                if (db < Double.parseDouble(tr.getNormArr().get(0)))
                    pro = 100 / 16;
                else if (db > Double.parseDouble(tr.getNormArr().get(0)) && db <= Double.parseDouble(tr.getNormArr().get(1)))
                    pro = 14 + (int) ((db - Double.parseDouble(tr.getNormArr().get(0))) * 14.3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                else if (db > Double.parseDouble(tr.getNormArr().get(1)) && db <= Double.parseDouble(tr.getNormArr().get(2)))
                    pro = 28 + (int) ((db - Double.parseDouble(tr.getNormArr().get(1))) * 14.3 / (Double.parseDouble(tr.getNormArr().get(2)) - Double.parseDouble(tr.getNormArr().get(1))));
                else if (db > Double.parseDouble(tr.getNormArr().get(2)) && db <= Double.parseDouble(tr.getNormArr().get(3)))
                    pro = 43 + (int) ((db - Double.parseDouble(tr.getNormArr().get(2))) * 14.3 / (Double.parseDouble(tr.getNormArr().get(3)) - Double.parseDouble(tr.getNormArr().get(2))));
                else if (db > Double.parseDouble(tr.getNormArr().get(3)) && db <= Double.parseDouble(tr.getNormArr().get(4)))
                    pro = 58 + (int) ((db - Double.parseDouble(tr.getNormArr().get(3))) * 14.3 / (Double.parseDouble(tr.getNormArr().get(4)) - Double.parseDouble(tr.getNormArr().get(3))));
                else if (db > Double.parseDouble(tr.getNormArr().get(4)) && db <= Double.parseDouble(tr.getNormArr().get(5)))
                    pro = 72 + (int) ((db - Double.parseDouble(tr.getNormArr().get(4))) * 14.3 / (Double.parseDouble(tr.getNormArr().get(5)) - Double.parseDouble(tr.getNormArr().get(4))));
                else if (db > Double.parseDouble(tr.getNormArr().get(5)))
                    pro = 86 + (int) ((db - Double.parseDouble(tr.getNormArr().get(5))) * 14.3 / 10);
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 14) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 14 && pro <= 28) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_1));
                    binding.value.setBackgroundResource(R.drawable.corners_line_1);
                    binding.hint.setBackgroundResource(R.color.C_1);
                } else if (pro > 28 && pro <= 42) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 42 && pro <= 56) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_3));
                    binding.value.setBackgroundResource(R.drawable.corners_line_3);
                    binding.hint.setBackgroundResource(R.color.C_3);
                } else if (pro > 56 && pro <= 70) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_4));
                    binding.value.setBackgroundResource(R.drawable.corners_line_4);
                    binding.hint.setBackgroundResource(R.color.C_4);
                } else if (pro > 70 && pro <= 84) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_5));
                    binding.value.setBackgroundResource(R.drawable.corners_line_5);
                    binding.hint.setBackgroundResource(R.color.C_5);
                } else if (pro > 84) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            case 2:
                binding.img.setImageResource(R.drawable.detail_icon_body_3bmi);
                binding.bg.setImageResource(R.drawable.bg_bmi);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i1.setVisibility(View.VISIBLE);
                binding.h1.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i3.setVisibility(View.VISIBLE);
                binding.h3.setVisibility(View.VISIBLE);
                binding.i4.setVisibility(View.VISIBLE);
                binding.h4.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("瘦");
                binding.h1.setText("偏瘦");
                binding.h2.setText("标准");
                binding.h3.setText("偏胖");
                binding.h4.setText("肥胖");
                binding.h6.setText("极度肥胖");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setText(tr.getNormArr().get(1));
                binding.v2.setVisibility(View.GONE);
                binding.v3.setText(tr.getNormArr().get(2));
                binding.v4.setText(tr.getNormArr().get(3));
                binding.v5.setText(tr.getNormArr().get(4));
                binding.line4.setVisibility(View.GONE);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue()) - 15) * 100 / 15);
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 17) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 17 && pro <= 34) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_1));
                    binding.value.setBackgroundResource(R.drawable.corners_line_1);
                    binding.hint.setBackgroundResource(R.color.C_1);
                } else if (pro > 34 && pro <= 51) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 51 && pro <= 68) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_3));
                    binding.value.setBackgroundResource(R.drawable.corners_line_3);
                    binding.hint.setBackgroundResource(R.color.C_3);
                } else if (pro > 68 && pro <= 85) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_4));
                    binding.value.setBackgroundResource(R.drawable.corners_line_4);
                    binding.hint.setBackgroundResource(R.color.C_4);
                } else if (pro > 85) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            case 3:
                binding.img.setImageResource(R.drawable.detail_icon_body_4zhifang);
                binding.bg.setImageResource(R.drawable.bg_tzl);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i3.setVisibility(View.VISIBLE);
                binding.h3.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("偏瘦");
                binding.h2.setText("标准");
                binding.h3.setText("偏胖");
                binding.h6.setText("肥胖");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setText(tr.getNormArr().get(1));
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(2));
                binding.line0.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                pro = (int) Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1)) * 100 / 35;
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 25) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 25 && pro <= 50) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 50 && pro <= 75) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_3));
                    binding.value.setBackgroundResource(R.drawable.corners_line_3);
                    binding.hint.setBackgroundResource(R.color.C_3);
                } else if (pro > 75) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            case 5:
                binding.img.setImageResource(R.drawable.detail_icon_body_6gugejilv);
                binding.bg.setImageResource(R.drawable.bg_ggjl);
                binding.i0.setVisibility(View.VISIBLE);
                binding.i0.setImageResource(R.drawable.circle_6);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.i6.setImageResource(R.drawable.circle_7);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("不足");
                binding.h2.setText("标准");
                binding.h6.setText("优");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                binding.linep.setBackgroundColor(getContext().getResources().getColor(R.color.C_6));
                binding.linepc.setImageResource(R.drawable.circle_6);
                binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_7));
                binding.line5c.setImageResource(R.drawable.circle_7);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_7));
                    binding.value.setBackgroundResource(R.drawable.corners_line_7);
                    binding.hint.setBackgroundResource(R.color.C_7);
                }
                break;
            case 6:
                binding.img.setImageResource(R.drawable.detail_icon_body_6gugejilv);
                binding.bg.setImageResource(R.drawable.bg_ggjl);
                binding.i0.setVisibility(View.VISIBLE);
                binding.i0.setImageResource(R.drawable.circle_6);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.i6.setImageResource(R.drawable.circle_7);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("不足");
                binding.h2.setText("标准");
                binding.h6.setText("优");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                binding.linep.setBackgroundColor(getContext().getResources().getColor(R.color.C_6));
                binding.linepc.setImageResource(R.drawable.circle_6);
                binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_7));
                binding.line5c.setImageResource(R.drawable.circle_7);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 2)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_7));
                    binding.value.setBackgroundResource(R.drawable.corners_line_7);
                    binding.hint.setBackgroundResource(R.color.C_7);
                }
                break;
            case 9:
                binding.img.setImageResource(R.drawable.detail_icon_body_10neizang);
                binding.bg.setImageResource(R.drawable.bg_tzl);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i3.setVisibility(View.VISIBLE);
                binding.h3.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("标准");
                binding.h3.setText("超标");
                binding.h6.setText("过多");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line1.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_3));
                    binding.value.setBackgroundResource(R.drawable.corners_line_3);
                    binding.hint.setBackgroundResource(R.color.C_3);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            case 10:
                binding.img.setImageResource(R.drawable.detail_icon_body_11shufien);
                binding.bg.setImageResource(R.drawable.bg_sf);
                binding.i0.setVisibility(View.VISIBLE);
                binding.i0.setImageResource(R.drawable.circle_6);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.i6.setImageResource(R.drawable.circle_7);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("不足");
                binding.h2.setText("标准");
                binding.h6.setText("优");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                binding.linep.setBackgroundColor(getContext().getResources().getColor(R.color.C_6));
                binding.linepc.setImageResource(R.drawable.circle_6);
                binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_7));
                binding.line5c.setImageResource(R.drawable.circle_7);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_7));
                    binding.value.setBackgroundResource(R.drawable.corners_line_7);
                    binding.hint.setBackgroundResource(R.color.C_7);
                }
                break;
            case 12:
                binding.img.setImageResource(R.drawable.detail_icon_body_13jichudaixie);
                binding.bg.setImageResource(R.drawable.bg_jcdx);
                binding.i0.setVisibility(View.VISIBLE);
                binding.i0.setImageResource(R.drawable.circle_6);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.i6.setImageResource(R.drawable.circle_7);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("未达标");
                binding.h6.setText("达标");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setVisibility(View.GONE);
                binding.line0.setVisibility(View.GONE);
                binding.line1.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                binding.linep.setBackgroundColor(getContext().getResources().getColor(R.color.C_6));
                binding.linepc.setImageResource(R.drawable.circle_6);
                binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_7));
                binding.line5c.setImageResource(R.drawable.circle_7);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue()) - 1000) / 10);
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 50) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                } else if (pro > 50) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_7));
                    binding.value.setBackgroundResource(R.drawable.corners_line_7);
                    binding.hint.setBackgroundResource(R.color.C_7);
                }
                break;
            case 13:
                binding.img.setImageResource(R.drawable.detail_icon_body_14guliang);
                binding.bg.setImageResource(R.drawable.bg_gl);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.i6.setImageResource(R.drawable.circle_7);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("偏低");
                binding.h2.setText("标准");
                binding.h6.setText("优");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                binding.line5.setBackgroundColor(getContext().getResources().getColor(R.color.C_7));
                binding.line5c.setImageResource(R.drawable.circle_7);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 2)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_7));
                    binding.value.setBackgroundResource(R.drawable.corners_line_7);
                    binding.hint.setBackgroundResource(R.color.C_7);
                }
                break;
            case 14:
                binding.img.setImageResource(R.drawable.detail_icon_body_15danbaizhi);
                binding.bg.setImageResource(R.drawable.bg_dbz);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("偏低");
                binding.h2.setText("标准");
                binding.h6.setText("偏高");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setVisibility(View.GONE);
                binding.v2.setVisibility(View.GONE);
                binding.v3.setVisibility(View.GONE);
                binding.v4.setVisibility(View.GONE);
                binding.v5.setText(tr.getNormArr().get(1));
                binding.line0.setVisibility(View.GONE);
                binding.line2.setVisibility(View.GONE);
                binding.line3.setVisibility(View.GONE);
                binding.line4.setVisibility(View.GONE);
                pro = (int) ((Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 1)) - 2 * Double.parseDouble(tr.getNormArr().get(0)) + Double.parseDouble(tr.getNormArr().get(1))) * 100 / 3 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 33) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 33 && pro <= 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 66) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            case 15:
                binding.img.setImageResource(R.drawable.detail_icon_body_16quzhitizhong);
                binding.bg.setImageResource(R.drawable.bg_tz);
                binding.line.setVisibility(View.GONE);
                binding.value.setTextColor(getResources().getColor(R.color.C_1));
                binding.value.setBackgroundResource(R.drawable.corners_line_1);
                binding.hint.setBackgroundResource(R.color.C_1);
                break;
            case 16:
                binding.img.setImageResource(R.drawable.detail_icon_body_17shentininaling);
                binding.bg.setImageResource(R.drawable.bg_tz);
                binding.line.setVisibility(View.GONE);
                binding.value.setTextColor(getResources().getColor(R.color.C_1));
                binding.value.setBackgroundResource(R.drawable.corners_line_1);
                binding.hint.setBackgroundResource(R.color.C_1);
                break;
            case 17:
                binding.img.setImageResource(R.drawable.detail_icon_body_16quzhitizhong);
                binding.bg.setImageResource(R.drawable.bg_tz);
                binding.i0.setVisibility(View.VISIBLE);
                binding.h0.setVisibility(View.VISIBLE);
                binding.i1.setVisibility(View.VISIBLE);
                binding.h1.setVisibility(View.VISIBLE);
                binding.i2.setVisibility(View.VISIBLE);
                binding.h2.setVisibility(View.VISIBLE);
                binding.i3.setVisibility(View.VISIBLE);
                binding.h3.setVisibility(View.VISIBLE);
                binding.i4.setVisibility(View.VISIBLE);
                binding.h4.setVisibility(View.VISIBLE);
                binding.i6.setVisibility(View.VISIBLE);
                binding.h6.setVisibility(View.VISIBLE);
                binding.h0.setText("瘦");
                binding.h1.setText("偏瘦");
                binding.h2.setText("标准");
                binding.h3.setText("偏胖");
                binding.h4.setText("肥胖");
                binding.h6.setText("极度肥胖");
                binding.v0.setText(tr.getNormArr().get(0));
                binding.v1.setText(tr.getNormArr().get(1));
                binding.v2.setVisibility(View.GONE);
                binding.v3.setText(tr.getNormArr().get(2));
                binding.v4.setText(tr.getNormArr().get(3));
                binding.v5.setText(tr.getNormArr().get(4));
                binding.line4.setVisibility(View.GONE);
                double di = Double.parseDouble(mTest_rp.getValue().substring(0, mTest_rp.getValue().length() - 2));
                if (di < Double.parseDouble(tr.getNormArr().get(0)))
                    pro = 100 / 12;
                else if (di > Double.parseDouble(tr.getNormArr().get(0)) && di < Double.parseDouble(tr.getNormArr().get(1)))
                    pro = 17 + (int) ((di - Double.parseDouble(tr.getNormArr().get(0))) * 17 / (Double.parseDouble(tr.getNormArr().get(1)) - Double.parseDouble(tr.getNormArr().get(0))));
                else if (di > Double.parseDouble(tr.getNormArr().get(1)) && di < Double.parseDouble(tr.getNormArr().get(2)))
                    pro = 34 + (int) ((di - Double.parseDouble(tr.getNormArr().get(1))) * 17 / (Double.parseDouble(tr.getNormArr().get(2)) - Double.parseDouble(tr.getNormArr().get(1))));
                else if (di > Double.parseDouble(tr.getNormArr().get(2)) && di < Double.parseDouble(tr.getNormArr().get(3)))
                    pro = 51 + (int) ((di - Double.parseDouble(tr.getNormArr().get(2))) * 17 / (Double.parseDouble(tr.getNormArr().get(3)) - Double.parseDouble(tr.getNormArr().get(2))));
                else if (di > Double.parseDouble(tr.getNormArr().get(3)) && di < Double.parseDouble(tr.getNormArr().get(4)))
                    pro = 68 + (int) ((di - Double.parseDouble(tr.getNormArr().get(3))) * 17 / (Double.parseDouble(tr.getNormArr().get(4)) - Double.parseDouble(tr.getNormArr().get(3))));
                else if (di > Double.parseDouble(tr.getNormArr().get(4)))
                    pro = 85 + (int) ((di - Double.parseDouble(tr.getNormArr().get(4))) * 17 / 8);
                binding.weightSB.setProgress(pro);
                binding.line.setVisibility(View.VISIBLE);
                if (pro <= 17) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_0));
                    binding.value.setBackgroundResource(R.drawable.corners_line_0);
                    binding.hint.setBackgroundResource(R.color.C_0);
                } else if (pro > 17 && pro <= 34) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_1));
                    binding.value.setBackgroundResource(R.drawable.corners_line_1);
                    binding.hint.setBackgroundResource(R.color.C_1);
                } else if (pro > 34 && pro <= 51) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_2));
                    binding.value.setBackgroundResource(R.drawable.corners_line_2);
                    binding.hint.setBackgroundResource(R.color.C_2);
                } else if (pro > 51 && pro <= 68) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_3));
                    binding.value.setBackgroundResource(R.drawable.corners_line_3);
                    binding.hint.setBackgroundResource(R.color.C_3);
                } else if (pro > 68 && pro <= 85) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_4));
                    binding.value.setBackgroundResource(R.drawable.corners_line_4);
                    binding.hint.setBackgroundResource(R.color.C_4);
                } else if (pro > 85) {
                    binding.value.setTextColor(getResources().getColor(R.color.C_6));
                    binding.value.setBackgroundResource(R.drawable.corners_line_6);
                    binding.hint.setBackgroundResource(R.color.C_6);
                }
                break;
            default:
                break;
        }
        binding.weightSB.setEnabled(false);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.data_fragment;
    }

    @Override
    protected Class getViewModelClass() {
        return ReportViewModel.class;
    }


}
